home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / doc / if_ruby.txt < prev    next >
Encoding:
Text File  |  2001-09-26  |  5.1 KB  |  174 lines

  1. *if_ruby.txt*   For Vim version 6.0.  Last change: 2001 Sep 03
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Shugo Maeda
  5.  
  6. The Ruby Interface to Vim                *ruby* *Ruby*
  7.  
  8.  
  9. 1. Commands            |ruby-commands|
  10. 2. The VIM module        |ruby-vim|
  11. 3. VIM::Buffer objects        |ruby-buffer|
  12. 4. VIM::Window objects        |ruby-window|
  13. 5. Global variables        |ruby-globals|
  14.  
  15. {Vi does not have any of these commands}
  16.             *E266* *E267* *E268* *E269* *E270* *E271* *E272* *E273*
  17.  
  18. The Ruby interface only works when Vim was compiled with the |+ruby| feature.
  19.  
  20. For MS-Windows you might find a Ruby library here:
  21.  
  22.     http://www.dm4lab.to/~usa/ruby_en.html
  23.  
  24. ==============================================================================
  25. 1. Commands                        *ruby-commands*
  26.  
  27.                             *:ruby* *:rub*
  28. :rub[y] {cmd}        Execute Ruby command {cmd}.
  29.  
  30. :rub[y] << {endpattern}
  31. {script}
  32. {endpattern}
  33.             Execute Ruby script {script}.
  34.             {endpattern} must NOT be preceded by any white space.
  35.             If {endpattern} is omitted, it defaults to a dot '.'
  36.             like for the |:append| and |:insert| commands. This
  37.             form of the |:ruby| command is mainly useful for
  38.             including ruby code in vim scripts.
  39.  
  40. Example Vim script: >
  41.  
  42.     function! RedGem()
  43.     ruby << EOF
  44.     class Garnet
  45.         def initialize(s)
  46.             @buffer = VIM::Buffer.current
  47.             vimputs(s)
  48.         end
  49.         def vimputs(s)
  50.             @buffer.append(@buffer.count,s)
  51.         end
  52.     end
  53.     gem = Garnet.new("pretty")
  54.     EOF
  55.     endfunction
  56. <
  57.  
  58.                         *:rubydo* *:rubyd* *E265*
  59. :[range]rubyd[o] {cmd}    Evaluate Ruby command {cmd} for each line in the
  60.             [range], with $_ being set to the text of each line in
  61.             turn, without a trailing <EOL>. Setting $_ will change
  62.             the text, but note that it is not possible to add or
  63.             delete lines using this command.
  64.             The default for [range] is the whole file: "1,$".
  65.  
  66.                             *:rubyfile* *:rubyf*
  67. :rubyf[ile] {file}    Execute the Ruby script in {file}.  This is the same as
  68.             ":ruby load 'file'", but allows file name completion.
  69.  
  70. Executing Ruby commands is not possible in the |sandbox|.
  71.  
  72. ==============================================================================
  73. 2. The VIM module                    *ruby-vim*
  74.  
  75. Ruby code gets all of its access to vim via the "VIM" module.
  76.  
  77. Overview >
  78.     print "Hello"            # displays a message
  79.     VIM.command(cmd)        # execute an ex command
  80.     num = VIM::Window.count        # gets the number of windows
  81.     w = VIM::Window[n]        # gets window "n"
  82.     cw = VIM::Window.current    # gets the current window
  83.     num = VIM::Buffer.count        # gets the number of buffers
  84.     b = VIM::Buffer[n]        # gets buffer "n"
  85.     cb = VIM::Buffer.current    # gets the current buffer
  86.     w.height = lines        # sets the window height
  87.     w.cursor = [row, col]        # sets the window cursor position
  88.     pos = w.cursor            # gets an array [row, col]
  89.     name = b.name            # gets the buffer file name
  90.     line = b[n]            # gets a line from the buffer
  91.     num = b.count            # gets the number of lines
  92.     b[n] = str            # sets a line in the buffer
  93.     b.delete(n)            # deletes a line
  94.     b.append(n, str)        # appends a line after n
  95. <
  96.  
  97. Module Functions:
  98.  
  99.                             *ruby-message*
  100. VIM::message({msg})
  101.     Displays the message {msg}.
  102.  
  103.                             *ruby-set_option*
  104. VIM::set_option({arg})
  105.     Sets a vim option.  {arg} can be any argument that the ":set" command
  106.     accepts.  Note that this means that no spaces are allowed in the
  107.     argument!  See |:set|.
  108.  
  109.                             *ruby-command*
  110. VIM::command({cmd})
  111.     Executes Ex command {cmd}.
  112.  
  113.                             *ruby-evaluate*
  114. VIM::evaluate({expr})
  115.     Evaluates {expr} using the vim internal expression evaluator (see
  116.     |expression|). Returns the expression result as a string.
  117.  
  118. ==============================================================================
  119. 3. VIM::Buffer objects                    *ruby-buffer*
  120.  
  121. VIM::Buffer objects represent vim buffers.
  122.  
  123. Class Methods:
  124.  
  125. current        Returns the current buffer object.
  126. count        Returns the number of buffers.
  127. self[{n}]    Returns the buffer object for the number {n}. The first number
  128.         is 0.
  129.  
  130. Methods:
  131.  
  132. name        Returns the name of the buffer.
  133. number        Returns the number of the buffer.
  134. count        Returns the number of lines.
  135. length        Returns the number of lines.
  136. self[{n}]    Returns a line from the buffer. {n} is the line number.
  137. self[{n}] = {str}
  138.         Sets a line in the buffer. {n} is the line number.
  139. delete({n})    Deletes a line from the buffer. {n} is the line number.
  140. append({n}, {str})
  141.         Appends a line after the line {n}.
  142.  
  143. ==============================================================================
  144. 4. VIM::Window objects                    *ruby-window*
  145.  
  146. VIM::Window objects represent vim windows.
  147.  
  148. Class Methods:
  149.  
  150. current        Returns the current window object.
  151. count        Returns the number of windows.
  152. self[{n}]    Returns the window object for the number {n}. The first number
  153.         is 0.
  154.  
  155. Methods:
  156.  
  157. buffer        Returns the buffer displayed in the window.
  158. height        Returns the height of the window.
  159. height = {n}    Sets the window height to {n}.
  160. cursor        Returns a [row, col] array for the cursor position.
  161. cursor = [{row}, {col}]
  162.         Sets the cursor position to {row} and {col}.
  163.  
  164. ==============================================================================
  165. 4. Global variables                    *ruby-globals*
  166.  
  167. There are two global variables.
  168.  
  169. $curwin        The current window object.
  170. $curbuf        The current buffer object.
  171.  
  172. ==============================================================================
  173.  vim:tw=78:ts=8:ft=help:norl:
  174.